﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TracNghiemV1.Database;
using TracNghiemV1.DAO;


namespace TracNghiemV1.BUS
{
    class QuestionBus
    {
        public static IList<QUESTION> GetQuestionList()
        {
            return QuestionDao.GetQuestionList();
        }

        public static void AddQuestion(QUESTION newQuestion)
        {
            QuestionDao.AddQuestion(newQuestion);
        }

        public static void DeleteQuestion(int questionId, IList<QUESTION_ITEM_INFO> lstItemInfo)
        {
            foreach (QUESTION_ITEM_INFO qii in lstItemInfo)
            {
                QuestionItemInfoDao.DeleteQuestionItemInfo(qii.ITEM_INFO_ID);
            }
            
            QuestionSolutionDao.DeleteQuestionSolution(questionId);
            QuestionItemDao.DeleteQuestionItem(questionId);
            QuestionTopicMapDao.DeleteQuestionTopicMap(questionId);
            QuestionDao.DeleteQuestion(questionId);
        }

        public static void ModifyQuestion(QUESTION qt)
        {
            QuestionDao.ModifyQuestion(qt);
        }

        public static QUESTION FindQuestionWithQuestionId(int questionId)
        {
           return QuestionDao.FindQuestionWithQuestionId(questionId);
        }

        public static IList<QUESTION> FindQuestionListWithDescription(string description, string userId)
        {
           return QuestionDao.FindQuestionListWithDescription(description, userId);
        }

        public static IList<TOPIC> FindTopicListWithQuestionId(int questionId)
        {
            return QuestionDao.FindTopicListWithQuestionId(questionId);
        }

        public static IList<QUESTION_ITEM_INFO> FindQuestionItemInfoWithQuestionId(int questionId)
        {
            return QuestionDao.FindQuestionItemInfoWithQuestionId(questionId);
        }

        public static IList<QUESTION_SOLUTION> FindQuestionSolutionListWithQuestionId(int questionId)
        {
            return QuestionDao.FindQuestionSolutionListWithQuestionId(questionId);
        }
    }
}
